#include "apple.h"

apple::apple()
{
       //苹果资源加载
        m_apple.load(":/myImage/images/苹果.png");

        //苹果位置
        m_X = 0;
        m_Y = 0;

        //苹果状态
        m_Free = true;

        //苹果速度
        m_Speed = 5;  //苹果速度为5

        //苹果矩形
        m_Rect.setWidth(m_apple.width());
        m_Rect.setHeight(m_apple.height());
        m_Rect.moveTo(m_X,m_Y);
}

void apple::updatePosition()
{
    //空闲状态，不计算坐标
    if(m_Free)
    {
        return;
    }

    m_Y += m_Speed;
    m_Rect.moveTo(m_X,m_Y);

    if(m_Y >= 768 + m_Rect.height())
    {
        m_Free = true;
    }
}
